require "badboy";
require "bblibs.utils";
require "ZhuYe";
require "util";
require "logUtil";
require "HuangGong"
require "ShuYuan"
require "FuZhai"
require "GuanQia"
require "setting"
require "badboy"
require "ZhuJieMian"
require "ZhuJieMian"
require "FuBen"


-- 关闭公告
function gg_close()
    x, y = findMultiColorInRegionFuzzy(0xfee34b, "-18|-9|0x180402,6|-23|0x180402,24|-17|0xfeec80,33|-6|0x180402,23|12|0xfee658,6|24|0x180402,-14|0|0x180402,-3|-13|0xfee34b,4|3|0xfee34b", 80, 0, 0, 1079, 1919, 0, 0)
    if x > -1 then

    end
end



function anQuanQuYu()

    jiaoChengHUD1 = createHUD()     --创建一个HUD
    showHUD(jiaoChengHUD1, "安全区域", fenBianLv.devToRun_x(35), "0xff980003", "0xff00A005", 0, 0, 0, 1080, 70)      --显示HUD内容

    jiaoChengHUD2 = createHUD()     --创建一个HUD
    showHUD(jiaoChengHUD2, "安全区域", fenBianLv.devToRun_x(55), "0xff980003", "0xff00A005", 0, 0, 230, 170, 300)     --变更显示的HUD内容

    jiaoChengHUD3 = createHUD()     --创建一个HUD
    showHUD(jiaoChengHUD3, "警告区域", fenBianLv.devToRun_x(55), "0xff0017FF", "0xffFFE800", 0, 944, 998, 135, 160)     --变更显示的HUD内容

    jiaoChengHUD4 = createHUD()     --创建一个HUD
    showHUD(jiaoChengHUD4, "禁止区域", fenBianLv.devToRun_x(30), "0xff00C1FF", "0xff980003", 0, 0, 550, 170, 70)     --变更显示的HUD内容

end

function anQuanQuYu_close2()
    hideHUD(jiaoChengHUD1)     --隐藏HUD
    hideHUD(jiaoChengHUD2)     --隐藏HUD
    hideHUD(jiaoChengHUD3)     --隐藏HUD
    hideHUD(jiaoChengHUD4)     --隐藏HUD
end

function anQuanQuYu_close()
    if bangZhuSet_quYu then
        logger("脚本将在5s秒后运行 " , LOG_INFO)
        mSleep(4000)
        anQuanQuYu_close2()
        logger("脚本开始运行 " , LOG_INFO)
    else
        anQuanQuYu_close2()
    end


end


--[[
function xuNiAnJian()
    point = findColors({2, 1788, 40, 1917},
    {
        {x=17,y=1823,color=0x000002}
    },
    99, 0, 0, 0)

    point = findMultiColorInRegionFuzzyExt(0x000002,"", 90, 97, 220, 903, 701)
    local tempTable={}
    if #point ~= 0 then  --如返回的table不为空（至少找到一个符合条件的点）
        for var = 1,#point do
            sysLog(point[var].x..":"..point[var].y)
           local temp= tempTable[point[var].y]
            if temp then
                temp={}
            end
            temp

        end
    end
end
]]


-----------------------  开始  -----
-- 设置日志级别
LOG_LEVEL = LOG_DEBUG;
init("0", 0);
setScreenScale(1080, 1920) --在540*960分辨率的手机中开发了脚本，要在720*1280的设备中运行 -

--开发信息
devX = 1080;
devY = 1920;

--运行信息
runX, runY = getScreenSize()

-- 倍率
rotX = runX / devX;
rotY = runY / devY;



anQuanQuYu()
--[[while true do
    FuBen.run()
		mSleep(2000)
end]]
showMyUi();
anQuanQuYu_close()
logger("当前手机分辨率 " .. tostring(runX) .. " X" .. tostring(runY), LOG_INFO)






function main_run()

    if gameType == gameTypeZiChan then
        while true do
            fz_only_ziChan()
        end
    end
    if results.gameType == gameTypeFuZai then
        while true do
            fz_fanHuiUi()
            fz_run()
        end
    end
    if results.gameType == gameTypeGuanQia then
        while true do
            gq_fanHuiUi()
            gq_run()
        end
    end

    if results.gameType == gameTypeQuanJu then
        while true do
            ZhuJieMian.fanHuiUi()
            ZhuJieMian.run()
        end
    end


end


if tostring(yesOrNo) == '1' then
    main_run()
end 





